package main

import (
	"fmt"
	"github.com/golang/protobuf/proto"
	"golang.org/x/net/context"
	"google.golang.org/grpc"
	"Gocode/study.com/RPCandgRPC/grpc/message"
	//"net/rpc"
)

func main() {

	names := []string{"小明"}
	//genders := []string{"男", "女"}
	//gender:=models.Gender(0)
	args := &message.UserRequest{
		Name: names,
		Age: *proto.Uint32(20),
		Gender: *proto.Int32(0),
	}
	//连接服务端
	conn, err := grpc.Dial("localhost:9000", grpc.WithInsecure())
	if err != nil {
		//panic(err.Error())
		fmt.Println("grpc.Dial error=", err)
		return
	}
	defer conn.Close()

	gRPCCliect := message.NewGetUserServiceClient(conn)

	user, err := gRPCCliect.GetUser(context.Background(), args)
	if err != nil {
		//panic(err.Error())
		fmt.Println(" gRPCCliect.GetUser error=", err)
		return
	}
	fmt.Printf("user=%v--%T\n",user,user)
	fmt.Println(user.GetGender())
	fmt.Println(user.GetAge())
	fmt.Println(user.GetName())
}
